package set

func Intersection(slice1, slice2 []int64) []int64 {
	elementMap := make(map[int64]struct{})
	for _, v := range slice1 {
		elementMap[v] = struct{}{}
	}

	var result []int64
	for _, v := range slice2 {
		if _, exists := elementMap[v]; exists {
			result = append(result, v)
		}
	}
	return result
}
